package cn.kwq.project_manger.repostitory;

import cn.kwq.project_manger.pojo.Role;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface RoleRepository extends JpaRepository<Role, Long>, CrudRepository<Role,Long> {

    @Query(value = "SELECT r.role_name FROM role r LEFT JOIN user_role a ON r.id=a.role_id WHERE a.user_id = ?1",nativeQuery = true)
    List<String> findRoleByUserId(Long userId);



}
